/*
 *  head.cpp
 *  bgsubtraction
 *
 *  Created by a1gucis on 4/5/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#include "head.h"
Head::Head() : BodyPart(3){
	this->hairLabel = -1;
	this->faceLabel = -1;
	this->mopCloseIterations = MOP_HEAD_CLOSE_ITERATIONS;
	this->hairBlobMatrixSize = HAIR_BLOB_MATRIX_SIZE;
	this->faceBlobMatrixSize = FACE_BLOB_MATRIX_SIZE;
}

Head::~Head() {
		
}

int Head::findHairLabel() {
	for (int i=0;i<labeledImage->height-hairBlobMatrixSize;i++) {
		for (int j=0;j<labeledImage->width-hairBlobMatrixSize;j++) {
			if (isBlob(i, j, hairBlobMatrixSize))
				hairLabel = (int)labeledImage->imageData[i*labeledImage->widthStep+j*labeledImage->nChannels];//labeledImage[i][j]
		}
	}
}

int Head::findFaceLabel() {
	int startRow = labeledImage->height/2;
	for (int i=startRow;i<labeledImage->height-faceBlobMatrixSize;i++) {
		for(int j=0;j<labeledImage->width-faceBlobMatrixSize;j++) {
			if (((int)labeledImage->imageData[i*labeledImage->widthStep+j*labeledImage->nChannels] != hairLabel) &&
				isBlob(i, j, faceBlobMatrixSize))
				faceLabel = (int)labeledImage->imageData[i*labeledImage->widthStep+j*labeledImage->nChannels];
		}
	}
}
int Head::getHairLabel() {
	return hairLabel;
}

int Head::getFaceLabel() {
	return faceLabel;
}